﻿using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using MouseExtender.Logic;

namespace MouseExtender.Controls.UserControls
{
    /// <summary>
    /// Interaction logic for AboutUC.xaml
    /// </summary>
    public partial class AboutUC : UserControl
    {
        public AboutUC()
        {
            InitializeComponent();
            this.DataContext = new
            {
                MeSiteUrlName = Constants.MeSiteUrl,
                MeSiteUrlTitle = "MouseExtender website",
                MeSiteUrl = new Uri(new Uri(Constants.MeSiteUrl), Constants.MeGoogleAnalyticsParams).AbsoluteUri
            };
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            runVersion.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            aboutBody.Focus();

            if (!File.Exists(Constants.ReleaseNotesFileName))
            {
                txtReleaseNotes.Visibility = Visibility.Collapsed;
            }
        }

        private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo(e.Uri.ToString());
            Process.Start(startInfo);
        }

        private void releaseNotes_Click(object sender, RoutedEventArgs e)
        {
            Process.Start(Constants.ReleaseNotesFileName);
        }
    }
}
